package com.qyhl.webtv.module_broke.utils.view;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.widget.LinearLayout;

import com.just.library.AgentWeb;
import com.qyhl.webtv.module_broke.R;

import razerdp.basepopup.BasePopupWindow;

import static com.qyhl.webtv.module_broke.common.BrokeUrl.AGREEMENT_URL;

/**
 * Created by qyhl on 2017/9/13.
 */

public class RulePopup extends BasePopupWindow {
    private View popupView;
    private AgentWeb mAgentWeb;
    private LinearLayout mLinearLayout;

    public RulePopup(Activity context) {
        super(context);
        bindEvent(context);
    }

    @Override
    protected Animation initShowAnimation() {
        return getDefaultScaleAnimation();
    }


    @Override
    public View getClickToDismissView() {
        return getPopupWindowView();
    }

    @Override
    public View onCreatePopupView() {
        popupView = LayoutInflater.from(getContext()).inflate(R.layout.broke_popup_scoop_rule, null);
        return popupView;
    }

    @Override
    public View initAnimaView() {
        return findViewById(R.id.popup_anima);
    }

    private void bindEvent(Activity context) {
        mLinearLayout = (LinearLayout) popupView.findViewById(R.id.web_layout);
        mAgentWeb = AgentWeb.with(context)//传入Activity or Fragment
                .setAgentWebParent(mLinearLayout, new LinearLayout.LayoutParams(-1, -1))//传入AgentWeb 的父控件 ，如果父控件为 RelativeLayout ， 那么第二参数需要传入 RelativeLayout.LayoutParams ,第一个参数和第二个参数应该对应。
                .useDefaultIndicator()// 使用默认进度条
                .defaultProgressBarColor() // 使用默认进度条颜色
                .createAgentWeb()//
                .ready()
                .go(AGREEMENT_URL);
    }
}
